<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>装修收款单</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/style.css" rel="stylesheet" type="text/css">
<link type="text/css" href="jquery/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
<script type="text/javascript" src="jquery/jquery.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui-1.8.19.custom.min.js"></script>
<script src="script/commons.js" type="text/javascript"></script>
<script src="script/calendar.js" type="text/javascript"></script>
<script src="script/objects.js" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(function(e) {
		<c:if test="${modifyObject != null}">
			$("#receiptId").val('${modifyObject.receiptId}');
			$("#receiptDate").val('${modifyObject.receiptDate}');
			$("#gatherWay").val('${modifyObject.gatherWay}');
			$("#customer").val('${modifyObject.finCustomer.customerid}');
			$("#receiptRemark").val(HTMLDecode(toNewLine('${modifyObject.receiptRemark}')));
			$("#receiptPrince").val('${modifyObject.receiptPrince}');
			// 指定制单日期
			$("#writeDate").val('${modifyObject.writeDate}');
			$("#wDate").html('${modifyObject.writeDate}');
			// 修改外观。修改导航标题
			$("#modifyTitle").text("修改");
			// 修改隐藏字段表示为修改模式
			$("#isModify").val("1");
			// 单据标号调整为只读
			$("#receiptId").attr("readonly", "readonly");
			setAlertLength();
		</c:if>
		<c:if test="${modifyObject == null}">
			$("#receiptId").val('${receiptId}');
			$("#isModify").val("0");
			$("#writeDate").val(getCurTime());
			$("#wDate").html(getCurTime());
		</c:if>
    });
	
	function check() {
		with (document.all) {
			if (customer.value == "") {
				alert("客户名称不允许为空");
				return false;
			}
			
			if (receiptPrince.value == "") {
				alert("请输入金额");
				$("#receiptPrince").focus();
				$("#receiptPrince").select();
				return false;
			} 
			if($("#receiptDate").val() == "") {
				alert("请选择日期");
				$("#receiptDate").click();
				return false;
			}
			if (isNaN(receiptPrince.value)) {
				alert("输入的金额必须是数字");
				$("#receiptPrince").focus();
				$("#receiptPrince").select();
				return false;
			}
			if(parseInt($("#alertLength").text()) < 0) {
				alert("备注的字数太多了。。。。只能写500字！");
				return false;
			}
			else {
				$("#receiptRemark").text(HTMLEncode($("#receiptRemark").text()));
				document.finreceiptForm.submit();
			}
		}
	}
</script>
<style>
#second {
	
}
#shop {
	visibility: hidden;
}
#setWidth {
	width: 100%;
}
</style>
</head>
<body>
<html:form method="post" action="receiptadd.do">
  <div id="setWidth">
  <div class="button_bar">
    <c:if test="${ (finuser.role.roleId == 1 or finuser.role.roleId == 3) or (modifyObject != null and !modifyObject.isClosed) }">
    	<input type="button" value="保存" onclick="check()">
    </c:if>
  </div>
  <table class="query_form_table detail_form_table">
    <tr>
      <th colspan="4"><span class="red_star">*</span>为必填项</th>
    </tr>
    <tr>
      <th>单据编号</th>
      <td id="second"><html:text property="receiptId" styleId="receiptId" readonly="true" />
        <span class="red_star">*</span></td>
      <th>日期</th>
      <td><html:text property="receiptDate" size="20" styleId="receiptDate"
						onclick="show_cele_date(this,'','',this)" readonly="true" />
        <span class="red_star">*</span></td>
    </tr>
    <tr>
      <th style="height: 32px;">制单日期</th>
      <td colspan="3"><span id="wDate"></span>
        <html:hidden property="writeDate" styleId="writeDate" /></td>
    </tr>
    <tr>
      <th>制单人</th>
      <td><html:text property="finUser" value="${finuser.uname}"
						readonly="true" /></td>
      <th>渠道名称</th>
      <td><html:select property="customer" onchange="getShops()" styleId="customer">
          <html:options collection="customers" property="customerid" labelProperty="customer" />
        </html:select></td>
    </tr>
    <tr>
      <th>收款方式</th>
      <td><html:select property="gatherWay" styleId="gatherWay">
          <html:option value="现金">现金</html:option>
          <html:option value="支票">支票</html:option>
        </html:select>
        <span class="red_star">*</span></td>
      <th>金额</th>
      <td><html:text property="receiptPrince" styleId="receiptPrince"></html:text>
        <span class="red_star">*</span></td>
    </tr>
    <tr>
      <th>备注</th>
      <td colspan="3"><html:textarea property="receiptRemark" styleId="receiptRemark" rows="9" cols="60"></html:textarea>
      <span class="alertLength">还可以写&nbsp;<span id="alertLength">500</span>&nbsp;个字</span></td>
    </tr>
  </table>
  </div>
  <html:hidden property="isModify" styleId="isModify" />
</html:form>
</body>
</html>